<tableRule name="rule1">
<rule>
<columns>id</columns>
<algorithm><![CDATA[ func1(${id}) ]]></algorithm>
</rule>
</tableRule>
<!-- 路由函数定义 -->
<function name="func1" class="com.alibaba.cobar.route.function.PartitionByLong">
<property name="partitionCount">2</property>
<property name="partitionLength">512</property>
</function>
```
&
```bash
<cobar:schema xmlns:cobar="http://cobar.alibaba.com/">
<!-- schema定义 -->
<schema name="cppdb" dataNode="cppDb1">
<table name="tb2" dataNode="cppDb2,cppDb3" rule="rule1" />
</schema>
<!-- 数据节点定义,数据节点由数据源和其他一些参数组织而成。-->
<dataNode name="cppDb1">
<property name="dataSource">
<dataSourceRef>cppDataSource[0]</dataSourceRef>
</property>
</dataNode>
<dataNode name="cppDb2">
<property name="dataSource">
<dataSourceRef>cppDataSource[1]</dataSourceRef>
</property>
</dataNode>
<dataNode name="cppDb3">
<property name="dataSource">
<dataSourceRef>cppDataSource[2]</dataSourceRef>
</property>
</dataNode>
<!-- 数据源定义,数据源是一个具体的后端数据连接的表示。-->
<dataSource name="cppDataSource" type="mysql">
<property name="location">
<location>172.22.14.7:3306/cpp1</location>
<location>172.22.14.7:3306/cpp2</location>
<location>172.22.14.7:3306/cpp3</location>
</property>
<property name="user">root</property>
<property name="password">root</property>
<property name="sqlMode">STRICT_TRANS_TABLES</property>
</dataSource>
</cobar:schema>